@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

:root{
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --primary: #0F2A44;
  --secondary: #2563EB;
  --accent: #22C55E;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;

  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);

  --radius: 14px;
}

*{ box-sizing:border-box; }
html, body{ height: 100%; }

body{
  margin:0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =========================
   Top (global) header
========================= */
.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248,250,252,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner{
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px;
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.title{
  font-weight: 800;
  font-size: 16px;
  margin-right:auto;
  display:flex;
  align-items:baseline;
  gap:10px;
}

.subtitle{
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}

.tabs{ display:flex; gap:8px; align-items:center; }

.tab{
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor:pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.tab:hover{
  border-color: rgba(37,99,235,.35);
  transform: translateY(-1px);
}

.tab[aria-selected="true"]{
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* =========================
   Main / panels
========================= */
main{ max-width: 1400px; margin: 0 auto; padding: 16px; }
.panel{ display:none; }
.panel.is-active{ display:block; }

/* =========================
   Report shell
========================= */
.report-canvas{
  background: transparent;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.report-inner{
  padding: 18px;
  min-height: 70vh;
}

/* =========================
   Dashboard header strip (lighter + shorter)
========================= */
.report-headerbar{
  background: #102E4B;
  color: #fff;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.headerbar-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.headerbar-title{
  text-align:center;
  flex: 1;
  font-weight: 800;
  letter-spacing: .2px;
  text-transform: uppercase;
  font-size: 14px;
  line-height: 1.1;
}

.headerbar-title small{
  display:block;
  margin-top: 4px;
  font-weight: 500;
  color: rgba(255,255,255,.78);
  text-transform:none;
  letter-spacing: 0;
  font-size: 12px;
}

.headerbar-logo{
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.16);
  filter: grayscale(.25) saturate(.85);
  opacity: .95;
}

/* =========================
   Layout
========================= */
.top-grid{
  display:grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items:start;
  margin-top: 14px;
}

@media(max-width: 1100px){
  .top-grid{ grid-template-columns: 1fr; }
}

/* =========================
   Cards
========================= */
.frame-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

/* =========================
   Filters panel + Collapsible header
========================= */
.control-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.control-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.control-head-title{
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.control-toggle{
  display:none; /* shown on mobile */
  border: 1px solid transparent;
  background: rgba(37,99,235,.10);
  color: var(--secondary);
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  cursor:pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.control-toggle:hover{
  background: rgba(37,99,235,.16);
  transform: translateY(-1px);
}

.control-body{
  overflow: hidden;
}

/* Collapse behavior (mobile) */
@media(max-width: 900px){
  .control-toggle{ display:inline-flex; align-items:center; gap:8px; }
  .control-card.is-collapsed .control-body{
    max-height: 0;
  }
  .control-card:not(.is-collapsed) .control-body{
    max-height: 900px;
  }
  .control-body{
    transition: max-height 260ms ease;
  }
}

/* Filters grid */
.control-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid-single{ grid-template-columns: 1fr; }


.field label{
  display:block;
  font-weight: 500;
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--muted);
}

.field .ghost{ opacity: 0; }

.field select,
.field input{
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #F1F5F9;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.field select:focus,
.field input:focus{
  outline: none;
  background: #FFFFFF;
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}

.field.actions{
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
}

.btn-row{
  display:flex;
  gap:8px;
  justify-content:flex-end;
}

.mini-btn{
  border: 1px solid transparent;
  background: rgba(37,99,235,.10);
  color: var(--secondary);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  cursor:pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.mini-btn:hover{
  background: rgba(37,99,235,.22);
  border-color: rgba(37,99,235,.18);
  transform: translateY(-1px);
}

.mini-btn:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}

.mini-btn.is-active{
  background: rgba(37,99,235,.28);
  border-color: rgba(37,99,235,.30);
  box-shadow: 0 6px 14px rgba(2, 6, 23, .08);
}

/* Exclude block */
.exclude-compact{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.exclude-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 8px;
}

.exclude-title{
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.link-btn{
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--secondary);
}

.link-btn:hover{ text-decoration: underline; }

.exclude-row{ display:flex; flex-direction:column; gap:8px; }

/* Expanders (Calendar / Exclude) - keeps existing look */
.expander:not(.exclude-compact){
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.expander-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 8px;
}

.expander-title{
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.expander-actions{
  display:flex;
  align-items:center;
  gap: 10px;
}

.exclude-pick{
  width:100%;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #F1F5F9;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.chips{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.chip{
  display:flex;
  align-items:center;
  gap:6px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text);
}

.chip button{
  border:none;
  background:transparent;
  cursor:pointer;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
}

.chip button:hover{ color: var(--text); }

/* =========================
   Status blocks
========================= */
.status-strip.framed{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items:stretch;
}

@media(max-width: 1200px){
  .status-strip.framed{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media(max-width: 650px){
  .status-strip.framed{ grid-template-columns: 1fr; }
}

.status-block{
  text-align:center;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  min-height: 170px;
}

.status-title{
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text);
  margin-top: 2px;
}

.status-line{
  height: 2px;
  width: 120px;
  background: var(--border);
  margin: 10px auto 0;
}

.status-center{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 10px 0 6px;
}

.status-bottom{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  width: 200px;
  margin: 0 auto;
  padding-top: 6px;
}

.stat-label{
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.stat-value{
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

/* Emoji: reduced dominance */
.emoji{
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display:grid;
  place-items:center;
  font-size: 34px;
  border: 1px solid rgba(226,232,240,.95);
  background: #FFFFFF;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

/* Battery */
.battery{
  width: 62px;
  height: 88px;
  border: 2px solid rgba(15,42,68,.55);
  border-radius: 12px;
  position: relative;
  background: #F1F5F9;
  padding: 8px;
  transform: translateY(6px);
}

.battery:before{
  content:"";
  position:absolute;
  top:-10px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 10px;
  border: 2px solid rgba(15,42,68,.55);
  border-bottom: none;
  border-radius: 9px 9px 0 0;
  background: #F1F5F9;
}

.battery-bars{
  display:grid;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 6px;
  height: 100%;
}

.bar{ border-radius: 6px; background: #CBD5E1; }
.bar.on{ background: var(--accent); }


/* =========================
   Dashboard compact metric rows (RPE / sRPE cards)
========================= */
.metric-rows{
  display:flex;
  flex-direction:column;
  gap: 8px;
  width: 100%;
  padding: 6px 6px 2px;
}

.metric-row{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 8px;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
}

.metric-row .label{
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.metric-row .value{
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.metric-icon{
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display:grid;
  place-items:center;
  border: 1px solid rgba(226,232,240,.95);
  background: #FFFFFF;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.metric-icon svg{
  width: 34px;
  height: 34px;
}

/* =========================
   Tables + Sticky first column + Zebra
========================= */
.table-wrap{
  margin-top: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow:auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table{
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 980px;
  font-size: 12.5px;
}

thead th{
  position: sticky;
  top: 0;
  background: var(--primary);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
  padding: 10px 8px;
  text-align:center;
  font-weight: 700;
  white-space: nowrap;
  z-index: 5;
}

/* Sticky first column (header + body) */
thead th:first-child{
  position: sticky;
  left: 0;
  z-index: 8;
  box-shadow: 6px 0 0 rgba(0,0,0,0); /* keeps layout stable */
}

tbody td{
  border-top: 1px solid var(--border);
  padding: 9px 8px;
  background: var(--surface);
  vertical-align: top;
  color: var(--text);
}

/* Zebra rows (do not touch heatmap cells) */
tbody tr:nth-child(even) td:not(.heat){
  background: #F8FAFC;
}

/* Hover (do not touch heatmap cells) */
tbody tr:hover td:not(.heat){
  background: #EEF2F7;
}

/* Sticky first column body */
tbody td:first-child{
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--surface);
  font-weight: 700;
  box-shadow: 8px 0 16px rgba(15,23,42,.06);
}

/* Keep zebra on sticky col too */
tbody tr:nth-child(even) td:first-child{ background: #F8FAFC; }
tbody tr:hover td:first-child{ background: #EEF2F7; }

/* Basic types */
tbody td.center{ text-align:center; font-weight: 600; }
tbody td.name{ font-weight: 700; }
tbody td.date{ font-weight: 600; white-space: nowrap; }

/* Heat cells: DO NOT override inline heat colors */
.heat{
  font-weight: 700;
  text-align:center;
  transition: background-color 220ms ease, color 220ms ease;
}

/* Comment column sizing */
.dash-table th:nth-child(8),
.dash-table td:nth-child(8){
  width: 340px;
  max-width: 420px;
  min-width: 280px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.25;
}

/* =========================
   Load KPIs
========================= */
.kpi-strip{
  display:flex;
  gap: 12px;
  align-items:stretch;
  justify-content:center;
}

.kpi-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 170px;
  text-align:center;
  box-shadow: var(--shadow);
}

.kpi-card-title{
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.kpi-card-value{
  font-weight: 800;
  font-size: 26px;
  margin-top: 6px;
  color: var(--text);
}

/* =========================
   Chart card
========================= */
.card{
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow:hidden;
  box-shadow: var(--shadow);
}

.card header{
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  color: var(--text);
}

.muted{ color: var(--muted); font-weight:500; }

.chart-frame{
  position:relative;
  width:100%;
  height: 82vh;
  background: var(--surface);
}

.chart-frame iframe{
  position:absolute; inset:0; width:100%; height:100%; border:0;
}

@media(max-width:768px){
  .chart-frame{ height: 92vh; }
}

/* ===============================
   Simple password gate overlay
   (doesn't change underlying layout)
   =============================== */
#authOverlay{
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 36, 0.78);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#authOverlay.is-open{ display: flex; }

#authCard{
  width: min(420px, 92vw);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  padding: 22px 22px 18px;
}
#authCard h2{
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: #0B2540;
}
#authCard p{
  margin: 0 0 14px;
  color: #35516b;
  font-size: 13px;
  line-height: 1.35;
}
#authRow{
  display: flex;
  gap: 10px;
  align-items: center;
}
#authPassword{
  flex: 1;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #d7e2ee;
  padding: 0 12px;
  outline: none;
  font-size: 14px;
}
#authPassword:focus{
  border-color: #9db7d3;
  box-shadow: 0 0 0 3px rgba(66,125,186,0.18);
}
#authBtn{
  height: 40px;
  border-radius: 12px;
  border: 0;
  padding: 0 14px;
  background: #0B2540;
  color: white;
  cursor: pointer;
  font-weight: 600;
}
#authError{
  min-height: 16px;
  margin-top: 10px;
  color: #b42318;
  font-size: 12px;
}
